package com.fixme4trade.view;

import java.util.Date;

import javax.inject.Inject;

import br.gov.frameworkdemoiselle.annotation.Name;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.gov.frameworkdemoiselle.util.Parameter;

import com.fixme4trade.business.ProductBC;
import com.fixme4trade.business.SellBC;
import com.fixme4trade.business.UserBC;
import com.fixme4trade.domain.Customer;
import com.fixme4trade.domain.Product;
import com.fixme4trade.domain.Sell;

@ViewController
@PreviousView("/sell_list.xhtml")
public class SellEditMB extends AbstractEditPageBean<Sell, Long> {

	private static final long serialVersionUID = 1L;
		
	@Inject
	private SellBC bc;

	@Override
	@Transactional
	public String delete() {
		this.bc.delete(getId());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String insert() {
		this.bc.insert(getBean());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String update() {
		this.bc.update(getBean());
		return getPreviousView();
	}

	@Override
	protected void handleLoad() {
		setBean(this.bc.load(getId()));
	}
}
